// component/filter/index.js
Component({
  behaviors: [],
  properties: {
    filterHidden:{
      type: Boolean,
      value:true,
    },
    filterList:{
      type: Array,
      value:[],
    }
  },
  data: {
   // 私有数据，可用于模版渲染
  },
  methods: {
    choose(e) {
      let parent = e.currentTarget.dataset.parent;
      let child = e.currentTarget.dataset.child;
      let select = e.currentTarget.dataset.select;
      let list = this.data.filterList[parent].list;
      if (!select) { list.forEach((item) => { item.isSelected = false; }); }
      list[child].isSelected = !select;
      this.data.filterList[parent].list = list;
      this.setData({ filterList: this.data.filterList });
    },
    emptyFilter() {
      this.data.filterList.forEach((filterItem) => { 
        filterItem.list.forEach((item)=>{
          item.isSelected = false;
        }) 
      });
      this.setData({
        filterList: this.data.filterList,
      })
			this.triggerEvent('emptyEvent');
    },
    confirm() {
      this.setData({ filterHidden: !this.data.filterHidden });
      this.triggerEvent('filterEvent', this.data.filterList);
    },
  }
})